package com.leancloud.home.fragment;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.alibaba.android.arouter.launcher.ARouter;
import com.aries.ui.view.title.TitleBarView;
import com.leancloud.home.R;
import com.leancloud.home.entity.MyUserInfoEntity;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
import com.vise.xsnow.event.IEvent;
import com.vise.xsnow.event.Subscribe;
import com.vise.xsnow.http.ViseHttp;
import com.vise.xsnow.http.callback.ACallback;

import tech.com.commoncore.base.BaseTitleFragment;
import tech.com.commoncore.basecomponent.ServiceFactory;
import tech.com.commoncore.constant.ApiConstant;
import tech.com.commoncore.manager.GlideManager;
import tech.com.commoncore.utils.OnNoDoubleClickListener;
import tech.com.commoncore.utils.StatusBarFontUtil;

public class HomeFragment extends BaseTitleFragment implements View.OnClickListener {


    private ImageView imgHuoqibao;
    private ImageView imgPaihang;
    private ImageView imgZhishubao;
    TextView tv_more;
    private TextView tvCjzx;
    private TextView tvJjbk;
    private TextView tvFejs;
    private TextView tvWdcs;

    public static HomeFragment newInstance() {
        Bundle args = new Bundle();
        HomeFragment fragment = new HomeFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void setTitleBar(TitleBarView titleBar) {
        titleBar.setLeftText(getResources().getString(R.string.home_app_name))
                .setLeftTextSize(25)
                .setStatusBarLightMode(true)
                .setTextColor(getResources().getColor(R.color.text_title))
                .setBackground(getResources().getDrawable(R.color.colorWhite));

    }

    @Override
    public int getContentLayout() {
        return R.layout.home_fragment_home1;
    }

    @Override
    public void initView(Bundle savedInstanceState) {
//        StatusBarFontUtil.setLightStatusBarColor(mContext);

//        setLayout();


        tv_more = (TextView) mContentView.findViewById(R.id.tv_more);
        imgHuoqibao = (ImageView) mContentView.findViewById(R.id.img_huoqibao);
        imgPaihang = (ImageView) mContentView.findViewById(R.id.img_paihang);
        imgZhishubao = (ImageView) mContentView.findViewById(R.id.img_zhishubao);
        tv_more.setOnClickListener(this);
        imgHuoqibao.setOnClickListener(this);
        imgPaihang.setOnClickListener(this);
        imgZhishubao.setOnClickListener(this);

        getChildFragmentManager().beginTransaction().replace(R.id.ll_huoqi_jinxuan,
                ServiceFactory.getInstance().getHangqingService().getHomeJxFragment()).commit();

        getChildFragmentManager().beginTransaction().replace(R.id.ll_hot_list,
                ServiceFactory.getInstance().getHangqingService().getHomeListFragment()).commit();

        getChildFragmentManager().beginTransaction().replace(R.id.ll_news_list,
                ServiceFactory.getInstance().getZixunService().newFlashFragment(null)).commit();



        tvCjzx = (TextView) mContentView.findViewById(R.id.tv_cjzx);
        tvJjbk = (TextView)  mContentView.findViewById(R.id.tv_jjbk);
        tvFejs = (TextView)  mContentView.findViewById(R.id.tv_fejs);
        tvWdcs = (TextView)  mContentView.findViewById(R.id.tv_wdcs);
        tvCjzx.setOnClickListener(this);
        tvJjbk.setOnClickListener(this);
        tvFejs.setOnClickListener(this);
        tvWdcs.setOnClickListener(this);
    }


    @Override
    public void onClick(View v) {
        int id = v.getId();
        //精选专题
        if (id == R.id.img_huoqibao) {
            ARouter.getInstance().build("/hq/HuoQiBao").navigation();
//            BusManager.getBus().post(new SwitchEvent(2));
        }
        if (id == R.id.img_paihang) {
            ARouter.getInstance().build("/hq/PaiHang").navigation();
        }
        if (id == R.id.img_zhishubao) {
            ARouter.getInstance().build("/hq/ZhiShuBao").navigation();
        }
        if (id == R.id.tv_more) {
            ARouter.getInstance().build("/hq/ZhiShuYouXuan").navigation();
        }
        if (id == R.id.tv_cjzx) {
            ARouter.getInstance().build("/zixun/CaiJingZiXun").navigation();
        }
        if (id == R.id.tv_jjbk) {
            ARouter.getInstance().build("/zixun/BaiKe").navigation();
        }
        if (id == R.id.tv_fejs) {
            ARouter.getInstance().build("/calculator/computing").navigation();
        }
        if (id == R.id.tv_wdcs) {
            ARouter.getInstance().build("/evaluation/start").navigation();
        }
    }

}
